import sys,math,os
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
class MenuDemo(QMainWindow):
    def __init__(self,parent=None):
        super(MenuDemo,self).__init__(parent)
        layout=QHBoxLayout()
        bar=self.menuBar()
        file=bar.addMenu("File")
        file.addAction("new")
        save=QAction("save",self)
        save.setShortcut("Ctrl+S")
        file.addAction(save)
        edit=file.addMenu("Edit")
        edit.addAction("copy")
        edit.addAction("paste")
        quit=QAction("Quit",self)
        file.addAction(quit)
        file.triggered.connect(self.processtriggered)
        self.setLayout(layout)
        self.setWindowTitle("menu案例")
    def processtriggered(self,q):
        print(q.text()+"点了")


if __name__ == '__main__':
    app=QApplication(sys.argv)
    demo=MenuDemo()
    demo.show()
    sys.exit(app.exec_())
